from django.db import models
from django.contrib.auth.models import User 
import datetime

# Create your models here.


class roletype(models.Model):
    """(roletypes description)"""
    name = models.CharField(blank=False, max_length=100)

    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"roletypes"


class objecttype(models.Model):
    """(objecttype description)"""
    name = models.CharField(blank=False, max_length=100)

    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"objecttype"



class tokentype(models.Model):
    """(tokentype description)"""
    name = models.CharField(blank=False, max_length=100)

    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"tokentype"

class token(models.Model):
    """(token description)"""
    name = models.CharField(blank=False, max_length=100)
    file = models.ImageField(upload_to="media/tokens", height_field=75, width_field=75)
    type = models.ForeignKey(tokentype)

    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"token"
                
class object(models.Model):
    """Characters"""
    user = models.ForeignKey(User)
    name = models.CharField(blank=False, max_length=100)
    image = models.ImageField(upload_to="/media", height_field=75, width_field=75)
    type = models.ForeignKey(objecttype)
    notes = models.TextField(blank=True)
    enabled = models.BooleanField(default=True)

    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"Modelname"

class group(models.Model):
    """(group description)"""
    name = models.CharField(blank=False, max_length=255)

    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"group"

class role(models.Model):
    """(role description)"""
    user = models.ForeignKey(User)
    group = models.ForeignKey(group)
    type = models.ForeignKey(roletype)

    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"role"
class map(models.Model):
    """(Location description)"""
    name = models.CharField(blank=False, max_length=100)
    file = models.FileField(upload_to=file)
    gridtype = models.CharField(blank=False, max_length=100)
    
    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"Location"

class location(models.Model):
    """(Location description)"""
    object = models.ForeignKey(object)
    map = models.ForeignKey(map)
    x = models.FloatField()
    y = models.FloatField()

    class Admin:
        list_display = ('',)
        search_fields = ('',)

    def __unicode__(self):
        return u"Location"


